#include "enemyplane2.h"
#include "config.h"

EnemyPlane2::EnemyPlane2()
{
    m_enemy.load(ENEMY2_PATH);
    m_x = 0;
    m_y = 0;
    m_Free = true;
    m_Speed = ENEMY2_SPEED;
    m_hitCount = 0;
    m_Rect.setWidth(m_enemy.width());
    m_Rect.setHeight(m_enemy.height());
    m_Rect.moveTo(m_x, m_y);
}

void EnemyPlane2::updatePosition()
{
    if (m_Free) return;
    m_y += m_Speed;
    m_Rect.moveTo(m_x, m_y);
    if (m_y >= gameheight + m_Rect.height()) {
        m_Free = true;
        m_hitCount = 0;
    }
}

bool EnemyPlane2::isDead()
{
    return m_hitCount >= 2;
}

void EnemyPlane2::hit()
{
    if (m_Free) return;
    m_hitCount++;
}
